<?php

declare (strict_types=1);

namespace cores;

// 应用请求对象类
class Request extends \think\Request
{
    // 全局过滤规则
    protected $filter = ['my_trim', 'my_htmlspecialchars', 'filter_emoji'];

    // 当前的商城ID (仅在访问store模块和api模块时有值)
    protected ?int $storeId = null;
    // 当前的商户ID (仅在访问shop模块有值)
    protected ?int $shopId = null;
    // 当前的商户ID (仅在访问shop模块有值)
    protected ?int $mendianId = null;


    /**
     * 获取当前的商城ID (仅在访问store模块和api模块时有值)
     * @return int
     */
    public function storeId(): int
    {
//        var_dump($this->storeId);
//        var_dump($this->header("storeId"));
//        $this->request("storeId");
        return (int)$this->storeId;
    }

    /**
     * 设置当前商城ID
     * @param int $storeId
     * @return $this
     */
    public function setStoreId(int $storeId): Request
    {

        $this->storeId = $storeId;
        return $this;
    }

    /**
     * 获取当前的商户ID (仅在访问shop模块有值)
     * @return int
     */
    public function shopId(): int
    {
        return (int)$this->shopId;
    }

    /**
     * 设置当前商户ID
     * @param int $shopId
     * @return $this
     */
    public function setShopId(int $shopId): Request
    {
        $this->shopId = $shopId;
        return $this;
    }

    /**
     * 获取当前的商户ID (仅在访问shop模块有值)
     * @return int
     */
    public function mendianId(): int
    {
        return (int)$this->mendianId;
    }

    /**
     * 设置当前商户ID
     * @param int $shopId
     * @return $this
     */
    public function setMendianId(int $mendianId): Request
    {
        $this->mendianId = $mendianId;
        return $this;
    }
}
